package com.credit.management.system.util;

import java.beans.PropertyEditorSupport;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DatePropertyEditor extends PropertyEditorSupport {
	private String [] formats;
	SimpleDateFormat sdf=new SimpleDateFormat();
@Override
public void setAsText(String text) throws IllegalArgumentException {
	for(int i=0;i<formats.length;i++){
		//解析时间格式
			sdf.applyPattern(formats[i]);
		try {//转为时间格式
			Date date=sdf.parse(text);
			//将转化为时间格式的值返回到xml
			setValue(date);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			//e.printStackTrace();
		}
	}	
}
public String[] getFormats() {
	return formats;
}
public void setFormats(String[] formats) {
	this.formats = formats;
}

}
